package minijvm.cmd;

import minijvm.clz.ClassFile;
import minijvm.engine.ExecutionResult;
import minijvm.engine.Heap;
import minijvm.engine.JavaObject;
import minijvm.engine.StackFrame;

/**
 * 将byte带符号 扩展为一个int类型的值 value
 * 然后将value压入到操作数栈中
 * @author ChangLiang
 * @date 2020/4/26
 */
public class BiPushCmd extends OneOperandCmd {

    protected BiPushCmd(ClassFile clzFile, String opCode) {
        super(clzFile, opCode);
    }

    @Override
    public void execute(StackFrame frame, ExecutionResult result) {
        int value = getOperand();
        JavaObject javaObject = Heap.getInstance().newInt(value);
        frame.getOperandStack().push(javaObject);
    }
}
